package tr.edu.metu.is550.isell.security.spring;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.UserDetails;
import tr.edu.metu.is550.isell.domain.User;

import java.util.Collection;

public class UserDetailsWrapper implements UserDetails {

    private User delegate;

    public UserDetailsWrapper(User user) {
        this.delegate = user;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return AuthorityUtils.createAuthorityList("ROLE_USER");
    }

    @Override
    public String getPassword() {
        return delegate.getUserCredentials().getPassword();
    }

    @Override
    public String getUsername() {
        return delegate.getUserCredentials().getLoginName();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
